﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="EN_OtsiAadressiIsk_query", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(ENOtsiAadressiIskQuery))]
    public class ENOtsiAadressiIskQuerySerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IENOtsiAadressiIskQuery clazz;
        
        public ENOtsiAadressiIskQuerySerializer(IENOtsiAadressiIskQuery clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Endised!=null) {
                Writer.WriteStartElement("endised");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Endised))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Synniaeg!=null) {
                Writer.WriteStartElement("synniaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Synniaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Nimi!=null) {
                Writer.WriteStartElement("nimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kood!=null) {
                Writer.WriteStartElement("kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Isikuliik!=null) {
                Writer.WriteStartElement("isikuliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuliik))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "eesnimi")) {
                goto eesnimi;
            }
            else {
                if ((Reader.LocalName == "endised")) {
                    goto endised;
                }
                else {
                    if ((Reader.LocalName == "synniaeg")) {
                        goto synniaeg;
                    }
                    else {
                        if ((Reader.LocalName == "nimi")) {
                            goto nimi;
                        }
                        else {
                            if ((Reader.LocalName == "kood")) {
                                goto kood;
                            }
                            else {
                                if ((Reader.LocalName == "isikuliik")) {
                                    goto isikuliik;
                                }
                                else {
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiIsk_query>eesnimi");
            }
            clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            goto START;
        endised:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiIsk_query>endised");
            }
            clazz.Endised = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("endised")).Value;
            goto START;
        synniaeg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiIsk_query>synniaeg");
            }
            clazz.Synniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synniaeg")).Value;
            goto START;
        nimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiIsk_query>nimi");
            }
            clazz.Nimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimi")).Value;
            goto START;
        kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiIsk_query>kood");
            }
            clazz.Kood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kood")).Value;
            goto START;
        isikuliik:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiIsk_query>isikuliik");
            }
            clazz.Isikuliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikuliik")).Value;
            goto START;
        }
    }
}
